def get_ip(request):
    """
    :param request:
    :return:
    """
    if "HTTP_X_FORWARDED_FOR" in request.META:
        ip = request.META['HTTP_X_FORWARDED_FOR']
        try:
            ip = ip.split(",")[0]
            return ip
        except Exception as e:
            print(e)
    else:
        ip = request.META['REMOTE_ADDR']
    return ip
